#pragma once

namespace TaskSync {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;
	using namespace System::IO;
	using namespace System::Text;

	/// <summary>
	/// Summary for Form1
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::MenuStrip^  menuStrip1;
	protected: 
	private: System::Windows::Forms::ToolStripMenuItem^  fileToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  openTask1ToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  openTask2ToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  saveNewTaskToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  exitToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  helpToolStripMenuItem;
	private: System::Windows::Forms::ToolStripMenuItem^  aboutToolStripMenuItem;
	private: System::Windows::Forms::DataGridView^  dataGridView1;



	private: System::Windows::Forms::Button^  button1;
	private: System::Windows::Forms::ProgressBar^  progressBar1;




	private: System::Windows::Forms::DataGridView^  dataGridView2;












	private: System::Windows::Forms::Label^  label1;
	private: System::Windows::Forms::Label^  label2;
	private: System::Windows::Forms::Label^  label3;
	private: System::Windows::Forms::Label^  label4;
	private: System::Windows::Forms::Label^  label5;
	private: System::Windows::Forms::Label^  label6;
	private: System::Windows::Forms::Label^  label7;
	private: System::Windows::Forms::Label^  label8;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  Pos;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  ID;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  Txt;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  dataGridViewTextBoxColumn1;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  dataGridViewTextBoxColumn2;
	private: System::Windows::Forms::DataGridViewTextBoxColumn^  dataGridViewTextBoxColumn3;

























	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->menuStrip1 = (gcnew System::Windows::Forms::MenuStrip());
			this->fileToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->openTask1ToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->openTask2ToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->saveNewTaskToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->exitToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->helpToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->aboutToolStripMenuItem = (gcnew System::Windows::Forms::ToolStripMenuItem());
			this->dataGridView1 = (gcnew System::Windows::Forms::DataGridView());
			this->button1 = (gcnew System::Windows::Forms::Button());
			this->progressBar1 = (gcnew System::Windows::Forms::ProgressBar());
			this->dataGridView2 = (gcnew System::Windows::Forms::DataGridView());
			this->label1 = (gcnew System::Windows::Forms::Label());
			this->label2 = (gcnew System::Windows::Forms::Label());
			this->label3 = (gcnew System::Windows::Forms::Label());
			this->label4 = (gcnew System::Windows::Forms::Label());
			this->label5 = (gcnew System::Windows::Forms::Label());
			this->label6 = (gcnew System::Windows::Forms::Label());
			this->label7 = (gcnew System::Windows::Forms::Label());
			this->label8 = (gcnew System::Windows::Forms::Label());
			this->Pos = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			this->ID = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			this->Txt = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			this->dataGridViewTextBoxColumn1 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			this->dataGridViewTextBoxColumn2 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			this->dataGridViewTextBoxColumn3 = (gcnew System::Windows::Forms::DataGridViewTextBoxColumn());
			this->menuStrip1->SuspendLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView1))->BeginInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView2))->BeginInit();
			this->SuspendLayout();
			// 
			// menuStrip1
			// 
			this->menuStrip1->Items->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(2) {this->fileToolStripMenuItem, 
				this->helpToolStripMenuItem});
			this->menuStrip1->Location = System::Drawing::Point(0, 0);
			this->menuStrip1->Name = L"menuStrip1";
			this->menuStrip1->Size = System::Drawing::Size(706, 24);
			this->menuStrip1->TabIndex = 0;
			this->menuStrip1->Text = L"menuStrip1";
			// 
			// fileToolStripMenuItem
			// 
			this->fileToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(4) {this->openTask1ToolStripMenuItem, 
				this->openTask2ToolStripMenuItem, this->saveNewTaskToolStripMenuItem, this->exitToolStripMenuItem});
			this->fileToolStripMenuItem->Name = L"fileToolStripMenuItem";
			this->fileToolStripMenuItem->Size = System::Drawing::Size(35, 20);
			this->fileToolStripMenuItem->Text = L"File";
			// 
			// openTask1ToolStripMenuItem
			// 
			this->openTask1ToolStripMenuItem->Name = L"openTask1ToolStripMenuItem";
			this->openTask1ToolStripMenuItem->Size = System::Drawing::Size(147, 22);
			this->openTask1ToolStripMenuItem->Text = L"Open Task 1";
			this->openTask1ToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::openTask1ToolStripMenuItem_Click);
			// 
			// openTask2ToolStripMenuItem
			// 
			this->openTask2ToolStripMenuItem->Name = L"openTask2ToolStripMenuItem";
			this->openTask2ToolStripMenuItem->Size = System::Drawing::Size(147, 22);
			this->openTask2ToolStripMenuItem->Text = L"Open Task 2";
			this->openTask2ToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::openTask2ToolStripMenuItem_Click);
			// 
			// saveNewTaskToolStripMenuItem
			// 
			this->saveNewTaskToolStripMenuItem->Name = L"saveNewTaskToolStripMenuItem";
			this->saveNewTaskToolStripMenuItem->Size = System::Drawing::Size(147, 22);
			this->saveNewTaskToolStripMenuItem->Text = L"Save New Task";
			this->saveNewTaskToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::saveNewTaskToolStripMenuItem_Click);
			// 
			// exitToolStripMenuItem
			// 
			this->exitToolStripMenuItem->Name = L"exitToolStripMenuItem";
			this->exitToolStripMenuItem->Size = System::Drawing::Size(147, 22);
			this->exitToolStripMenuItem->Text = L"Exit";
			this->exitToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::exitToolStripMenuItem_Click);
			// 
			// helpToolStripMenuItem
			// 
			this->helpToolStripMenuItem->DropDownItems->AddRange(gcnew cli::array< System::Windows::Forms::ToolStripItem^  >(1) {this->aboutToolStripMenuItem});
			this->helpToolStripMenuItem->Name = L"helpToolStripMenuItem";
			this->helpToolStripMenuItem->Size = System::Drawing::Size(40, 20);
			this->helpToolStripMenuItem->Text = L"Help";
			// 
			// aboutToolStripMenuItem
			// 
			this->aboutToolStripMenuItem->Name = L"aboutToolStripMenuItem";
			this->aboutToolStripMenuItem->Size = System::Drawing::Size(103, 22);
			this->aboutToolStripMenuItem->Text = L"About";
			// 
			// dataGridView1
			// 
			this->dataGridView1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom) 
				| System::Windows::Forms::AnchorStyles::Left));
			this->dataGridView1->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
			this->dataGridView1->CellBorderStyle = System::Windows::Forms::DataGridViewCellBorderStyle::Sunken;
			this->dataGridView1->ColumnHeadersBorderStyle = System::Windows::Forms::DataGridViewHeaderBorderStyle::Sunken;
			this->dataGridView1->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
			this->dataGridView1->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^  >(3) {this->Pos, this->ID, 
				this->Txt});
			this->dataGridView1->Location = System::Drawing::Point(12, 40);
			this->dataGridView1->Name = L"dataGridView1";
			this->dataGridView1->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
			this->dataGridView1->Size = System::Drawing::Size(332, 238);
			this->dataGridView1->TabIndex = 1;
			// 
			// button1
			// 
			this->button1->Anchor = System::Windows::Forms::AnchorStyles::Bottom;
			this->button1->Font = (gcnew System::Drawing::Font(L"Tahoma", 12, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->button1->Location = System::Drawing::Point(308, 284);
			this->button1->Name = L"button1";
			this->button1->Size = System::Drawing::Size(92, 42);
			this->button1->TabIndex = 3;
			this->button1->Text = L"Tranfers";
			this->button1->UseVisualStyleBackColor = true;
			this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
			// 
			// progressBar1
			// 
			this->progressBar1->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left) 
				| System::Windows::Forms::AnchorStyles::Right));
			this->progressBar1->Location = System::Drawing::Point(12, 332);
			this->progressBar1->Name = L"progressBar1";
			this->progressBar1->Size = System::Drawing::Size(682, 21);
			this->progressBar1->Style = System::Windows::Forms::ProgressBarStyle::Continuous;
			this->progressBar1->TabIndex = 4;
			// 
			// dataGridView2
			// 
			this->dataGridView2->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom) 
				| System::Windows::Forms::AnchorStyles::Right));
			this->dataGridView2->BorderStyle = System::Windows::Forms::BorderStyle::Fixed3D;
			this->dataGridView2->CellBorderStyle = System::Windows::Forms::DataGridViewCellBorderStyle::Sunken;
			this->dataGridView2->ColumnHeadersBorderStyle = System::Windows::Forms::DataGridViewHeaderBorderStyle::Sunken;
			this->dataGridView2->ColumnHeadersHeightSizeMode = System::Windows::Forms::DataGridViewColumnHeadersHeightSizeMode::AutoSize;
			this->dataGridView2->Columns->AddRange(gcnew cli::array< System::Windows::Forms::DataGridViewColumn^  >(3) {this->dataGridViewTextBoxColumn1, 
				this->dataGridViewTextBoxColumn2, this->dataGridViewTextBoxColumn3});
			this->dataGridView2->Location = System::Drawing::Point(362, 40);
			this->dataGridView2->Name = L"dataGridView2";
			this->dataGridView2->Size = System::Drawing::Size(332, 238);
			this->dataGridView2->TabIndex = 5;
			// 
			// label1
			// 
			this->label1->AutoSize = true;
			this->label1->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->label1->Location = System::Drawing::Point(38, 298);
			this->label1->Name = L"label1";
			this->label1->Size = System::Drawing::Size(32, 16);
			this->label1->TabIndex = 6;
			this->label1->Text = L"Ver:";
			// 
			// label2
			// 
			this->label2->AutoSize = true;
			this->label2->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->label2->Location = System::Drawing::Point(76, 298);
			this->label2->Name = L"label2";
			this->label2->Size = System::Drawing::Size(34, 16);
			this->label2->TabIndex = 7;
			this->label2->Text = L" N/A";
			// 
			// label3
			// 
			this->label3->AutoSize = true;
			this->label3->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->label3->Location = System::Drawing::Point(171, 299);
			this->label3->Name = L"label3";
			this->label3->Size = System::Drawing::Size(45, 16);
			this->label3->TabIndex = 8;
			this->label3->Text = L"No.ID:";
			// 
			// label4
			// 
			this->label4->AutoSize = true;
			this->label4->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->label4->Location = System::Drawing::Point(219, 299);
			this->label4->Name = L"label4";
			this->label4->Size = System::Drawing::Size(34, 16);
			this->label4->TabIndex = 9;
			this->label4->Text = L" N/A";
			// 
			// label5
			// 
			this->label5->AutoSize = true;
			this->label5->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->label5->Location = System::Drawing::Point(436, 299);
			this->label5->Name = L"label5";
			this->label5->Size = System::Drawing::Size(32, 16);
			this->label5->TabIndex = 10;
			this->label5->Text = L"Ver:";
			// 
			// label6
			// 
			this->label6->AutoSize = true;
			this->label6->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->label6->Location = System::Drawing::Point(474, 299);
			this->label6->Name = L"label6";
			this->label6->Size = System::Drawing::Size(34, 16);
			this->label6->TabIndex = 11;
			this->label6->Text = L" N/A";
			// 
			// label7
			// 
			this->label7->AutoSize = true;
			this->label7->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->label7->Location = System::Drawing::Point(562, 299);
			this->label7->Name = L"label7";
			this->label7->Size = System::Drawing::Size(45, 16);
			this->label7->TabIndex = 12;
			this->label7->Text = L"No.ID:";
			// 
			// label8
			// 
			this->label8->AutoSize = true;
			this->label8->Font = (gcnew System::Drawing::Font(L"Microsoft Sans Serif", 9.75F, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Point, 
				static_cast<System::Byte>(0)));
			this->label8->Location = System::Drawing::Point(613, 299);
			this->label8->Name = L"label8";
			this->label8->Size = System::Drawing::Size(34, 16);
			this->label8->TabIndex = 13;
			this->label8->Text = L" N/A";
			// 
			// Pos
			// 
			this->Pos->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::AllCells;
			this->Pos->Frozen = true;
			this->Pos->HeaderText = L"Pos";
			this->Pos->Name = L"Pos";
			this->Pos->Resizable = System::Windows::Forms::DataGridViewTriState::True;
			this->Pos->Width = 50;
			// 
			// ID
			// 
			this->ID->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::AllCells;
			this->ID->Frozen = true;
			this->ID->HeaderText = L"ID";
			this->ID->Name = L"ID";
			this->ID->Width = 43;
			// 
			// Txt
			// 
			this->Txt->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::Fill;
			this->Txt->HeaderText = L"Txt";
			this->Txt->Name = L"Txt";
			// 
			// dataGridViewTextBoxColumn1
			// 
			this->dataGridViewTextBoxColumn1->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::AllCells;
			this->dataGridViewTextBoxColumn1->Frozen = true;
			this->dataGridViewTextBoxColumn1->HeaderText = L"Pos";
			this->dataGridViewTextBoxColumn1->Name = L"dataGridViewTextBoxColumn1";
			this->dataGridViewTextBoxColumn1->Resizable = System::Windows::Forms::DataGridViewTriState::True;
			this->dataGridViewTextBoxColumn1->Width = 50;
			// 
			// dataGridViewTextBoxColumn2
			// 
			this->dataGridViewTextBoxColumn2->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::AllCells;
			this->dataGridViewTextBoxColumn2->Frozen = true;
			this->dataGridViewTextBoxColumn2->HeaderText = L"ID";
			this->dataGridViewTextBoxColumn2->Name = L"dataGridViewTextBoxColumn2";
			this->dataGridViewTextBoxColumn2->Width = 43;
			// 
			// dataGridViewTextBoxColumn3
			// 
			this->dataGridViewTextBoxColumn3->AutoSizeMode = System::Windows::Forms::DataGridViewAutoSizeColumnMode::Fill;
			this->dataGridViewTextBoxColumn3->HeaderText = L"Txt";
			this->dataGridViewTextBoxColumn3->Name = L"dataGridViewTextBoxColumn3";
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(706, 359);
			this->Controls->Add(this->label8);
			this->Controls->Add(this->label7);
			this->Controls->Add(this->label6);
			this->Controls->Add(this->label5);
			this->Controls->Add(this->label4);
			this->Controls->Add(this->label3);
			this->Controls->Add(this->label2);
			this->Controls->Add(this->label1);
			this->Controls->Add(this->dataGridView2);
			this->Controls->Add(this->progressBar1);
			this->Controls->Add(this->button1);
			this->Controls->Add(this->dataGridView1);
			this->Controls->Add(this->menuStrip1);
			this->MainMenuStrip = this->menuStrip1;
			this->MaximizeBox = false;
			this->Name = L"Form1";
			this->Text = L"Task Sync";
			this->menuStrip1->ResumeLayout(false);
			this->menuStrip1->PerformLayout();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView1))->EndInit();
			(cli::safe_cast<System::ComponentModel::ISupportInitialize^  >(this->dataGridView2))->EndInit();
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
		String^ File1;
private: System::Void openTask1ToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
			 OpenFileDialog^ tLoad = gcnew OpenFileDialog;
			 UnicodeEncoding^ unicode = gcnew UnicodeEncoding;
			 tLoad->Filter = "Tasks File (Tasks.*)|tasks.*|AllFile (*.*)|*.*";
			 int Pos, ID;
			 array<unsigned char>^ Name;
			 if (tLoad->ShowDialog() == System::Windows::Forms::DialogResult::OK && File::Exists(tLoad->FileName)){
				 File1 = tLoad->FileName;
				 dataGridView1->Rows->Clear();
				 FileStream^ fs = File::OpenRead(tLoad->FileName);
				 BinaryReader^ br = gcnew BinaryReader(fs);
				 int Head = br->ReadInt32();
				 int Len = br->ReadInt32();
				 label2->Text = Head.ToString();
				 label4->Text = Len.ToString();
		         progressBar1->Maximum = Len;
				 for (int i=0; i<Len; i++){
					 br->BaseStream->Seek(8+i*4, SeekOrigin::Begin);
					 Pos = br->ReadInt32();
						 br->BaseStream->Seek(Pos, SeekOrigin::Begin);
						 ID = br->ReadInt32();
						 Name = br->ReadBytes(64);
						 dataGridView1->Rows->Add(Pos.ToString(), ID.ToString(), unicode->GetString(Name));
					 progressBar1->Value = i;
				 }
				 fs->Close();
			 }
		 }
private: System::Void openTask2ToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
			 OpenFileDialog^ tLoad = gcnew OpenFileDialog;
			 UnicodeEncoding^ unicode = gcnew UnicodeEncoding;
			 tLoad->Filter = "Tasks File (Tasks.*)|tasks.*|AllFile (*.*)|*.*";
			 int Pos, ID;
			 array<unsigned char>^ Name;
			 if (tLoad->ShowDialog() == System::Windows::Forms::DialogResult::OK && File::Exists(tLoad->FileName)){
				 dataGridView2->Rows->Clear();
				 UnicodeEncoding^ unicode = gcnew UnicodeEncoding;
				 FileStream^ fs = File::OpenRead(tLoad->FileName);
				 BinaryReader^ br = gcnew BinaryReader(fs);
				 int Head = br->ReadInt32();
				 int Len = br->ReadInt32();
				 label6->Text = Head.ToString();
				 label8->Text = Len.ToString();
				 progressBar1->Maximum = Len;
				 for (int i=0; i<Len; i++){
					 br->BaseStream->Seek(8+i*4, SeekOrigin::Begin);
					 Pos = br->ReadInt32();
					 br->BaseStream->Seek(Pos, SeekOrigin::Begin);
					 ID = br->ReadInt32();
					 Name = br->ReadBytes(64);
					 dataGridView2->Rows->Add(Pos.ToString(), ID.ToString(), unicode->GetString(Name));
					 progressBar1->Value = i;
				 }
				 fs->Close();
			 }
		 }
private: System::Void saveNewTaskToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
			 SaveFileDialog^ tSave = gcnew SaveFileDialog;
			 tSave->Filter = "Tasks File (Tasks.*)|tasks.data*|AllFile (*.*)|*.*";
			 if (tSave->ShowDialog() == System::Windows::Forms::DialogResult::OK){
				 progressBar1->Maximum = Convert::ToInt32(label4->Text);
				 FileStream^ fs = File::OpenWrite(tSave->FileName);
				 FileStream^ fsload = File::OpenRead(File1);
				 BinaryWriter^ br = gcnew BinaryWriter(fs);
				 BinaryReader^ brload = gcnew BinaryReader(fsload);
				 UnicodeEncoding^ unicode = gcnew UnicodeEncoding;
				 br->Write(Convert::ToInt32(label2->Text));
				 br->Write(Convert::ToInt32(label4->Text));
				 for (int i=0; i<Convert::ToInt32(label4->Text); i++){
					 br->BaseStream->Seek(8+i*4, SeekOrigin::Begin);
					 br->Write(Convert::ToInt32(dataGridView1->Rows[i]->Cells[0]->Value));
					 br->BaseStream->Seek(Convert::ToInt32(dataGridView1->Rows[i]->Cells[0]->Value), SeekOrigin::Begin);
					 br->Write(Convert::ToInt32(dataGridView1->Rows[i]->Cells[1]->Value));
					 br->Write(unicode->GetBytes(Convert::ToString(dataGridView1->Rows[i]->Cells[2]->Value)));
					 if(i<Convert::ToInt32(label4->Text)-1){
						 brload->BaseStream->Seek(br->BaseStream->Position,SeekOrigin::Begin);
						 br->Write(brload->ReadBytes(Convert::ToInt32(dataGridView1->Rows[i+1]->Cells[0]->Value)-Convert::ToInt32(dataGridView1->Rows[i]->Cells[0]->Value)-68));
					 }
					 else{
						 brload->BaseStream->Seek(br->BaseStream->Position, SeekOrigin::End);
						 int leg = brload->BaseStream->Position;
						 brload->BaseStream->Seek(br->BaseStream->Position, SeekOrigin::Begin);
						 br->Write(brload->ReadBytes(leg));
					 }
					 progressBar1->Value = i;
				 }
				 fs->Close();
				 fsload->Close();
			 }

		 }
private: System::Void exitToolStripMenuItem_Click(System::Object^  sender, System::EventArgs^  e) {
			 Application::Exit();
		 }
private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
			 for (int i=0, j=0; i<Convert::ToInt32(label4->Text); i++){
				 for(; j<Convert::ToInt32(label8->Text); j++){
					 if(Convert::ToInt32(dataGridView1->Rows[i]->Cells[1]->Value) == Convert::ToUInt32(dataGridView2->Rows[j]->Cells[1]->Value)){
						 dataGridView1->Rows[i]->Cells[2]->Value = dataGridView2->Rows[j]->Cells[2]->Value;
						 j++;
						 break;
					 }
					 if(Convert::ToInt32(dataGridView1->Rows[i]->Cells[1]->Value) < Convert::ToUInt32(dataGridView2->Rows[j]->Cells[1]->Value)){
						 break;
					 }
				 }
			 }
		 }
};
}

